package com.study.d030animation;

import javafx.animation.FadeTransition;
import javafx.animation.FillTransition;
import javafx.animation.Interpolator;
import javafx.animation.PauseTransition;
import javafx.animation.RotateTransition;
import javafx.animation.ScaleTransition;
import javafx.animation.SequentialTransition;
import javafx.animation.Timeline;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Point3D;
import javafx.scene.Scene;
import javafx.scene.chart.Axis;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
*@description
*@author xtayhame
*date 2020年3月22日
*version
*since v1.0
*/
public class PauseTransitionMain  extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		HBox hBox = new HBox(20);
		Button b1=new Button("播放");
		Button b2=new Button("暂停");
		Button b3=new Button("停止");
		Button b4=new Button("设置加速");
		Button b7=new Button("从第二个点开始");

		Rectangle rectangle = new Rectangle(70, 70,Paint.valueOf("#EE82EE55"));

		hBox.getChildren().addAll(b1,b2,b3,b4,b7);
		anchorPane.getChildren().addAll(hBox,rectangle);
		AnchorPane.setTopAnchor(rectangle, 70.0);
		AnchorPane.setLeftAnchor(rectangle, 70.0);

		AnchorPane.setTopAnchor(rectangle, 80.0);
		AnchorPane.setLeftAnchor(rectangle, 100.0);

		stage.setScene(new Scene(anchorPane, 800, 600));
		stage.show();

		RotateTransition rt = new RotateTransition(Duration.seconds(5),rectangle);
		rt.setFromAngle(0);
		rt.setToAngle(720);
		rt.setAutoReverse(true);

		SequentialTransition seq = new SequentialTransition(new PauseTransition(Duration.millis(1000)));



		seq.getChildren().add(rt);

		rt.setCycleCount(Timeline.INDEFINITE);



		b1.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				System.out.println("开始");
				seq.play();
			}
		});
	}



}

